Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a separate tsconfig file to specify jsx mode for ts-jest vs next.js #9

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

rocketnova
Copy link
Contributor

@rocketnova rocketnova commented Jun 7, 2022

Ticket

Changes

What was added, updated, or removed in this PR.

  • Modifies tsconfig.json to use jsx mode preserve
  • Introduces tsconfig.ts-jest.json to allow ts-jest to use jsx mode react-jsx

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. Explain how the changes were verified.

Next.js requires the typescript jsx mode to be preserve and will make a mandatory correction when you run yarn dev or yarn build with the following message:

The following mandatory changes were made to your tsconfig.json:

  • jsx was set to preserve (next.js implements its own optimized jsx transform)

However, ts-jest needs it to be a flavor of react.

For more info, see:

Testing

Screenshots, GIF demos, code examples or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox.

  1. Run yarn install
  2. Run yarn dev. The dev server should start up with no complaints (the message above should not be displayed).
  3. Run yarn test. The tests should pass and should not return the failure "Jest encountered an unexpected token"

@karinamzalez
Copy link
Contributor

thanks for doing this!!

@rocketnova rocketnova merged commit 1b80699 into main Jun 16, 2022
@rocketnova rocketnova deleted the rocket/fix-jsx branch June 16, 2022 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants